home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / edgetext / clsemplo.cl_ / clsemplo.cl
Encoding:
Text File  |  1998-03-21  |  52.7 KB  |  1,414 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. End
  5. Attribute VB_Name = "clsEmployee"
  6. Attribute VB_Creatable = True
  7. Attribute VB_PredeclaredId = False
  8. Attribute VB_Exposed = False
  9. Option Explicit
  10. '**************************************************************************************
  11. 'Title:     clsEmployee.cls 
  12. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  13. 'Purpose:   This class allows single record access to the Employee Table 
  14. 'Properties:Equate to the fields in the table
  15. 'Methods:   Allow for record manipulation
  16.  
  17.  
  18. 'It is recommended that the Database object Dbtimesheet be declared global
  19.  
  20. 'It is also recommended that the Configuration object be declared global if it is being used
  21. 'This is so that it can be persistent
  22. '**************************************************************************************
  23.  
  24. 'Here are the Field Properties for this table Class
  25. Public Employee_Id as Long
  26. Public Employee_Name as String
  27. Public Employee_SS as String
  28. Public Updated_By as String
  29. Public Update_Module as String
  30. Public Update_Time as String
  31.  
  32. 'These are the ScratchPad Variables
  33. Private mEmployee_Id as Long
  34. Private mEmployee_Name as String
  35. Private mEmployee_SS as String
  36. Private mUpdated_By as String
  37. Private mUpdate_Module as String
  38. Private mUpdate_Time as String
  39.  
  40. 'This public variable tells whether a function was successful, it is True when a function
  41. 'is successful, and false when a function is unsuccessful
  42. Public Success as Boolean
  43. 'This is the Error Code which was generated in the function call, it matches Err from VB
  44. Public ErrorCode as Double
  45. 'This is the Error message which was generated in the function call, it matches Errors(0) VB
  46. Public ErrorMessage as String
  47. 'This Constant tells the error traps how many retries to perform
  48. Private Const MaxRetries = 4
  49.  
  50. '********************************************************************************************************
  51. 'Title:     CreateTable
  52. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  53. 'Purpose:   This subroutine Creates the very table that this class was created to read and write    
  54. 'Parameters:None
  55. 'Return:    Nothing
  56. '********************************************************************************************************
  57. Public Sub CreateTable()
  58.  
  59. Dim lsCreate as string
  60. Dim RetCode as integer, liCount as integer, BadCount as integer
  61.  
  62.     'The Success flag gets initialized to True and set to false if a trappable error occurs
  63.     Success = True
  64.     'The ErrorCode is the Err returned by VB for the Trapped Error
  65.     ErrorCode = False
  66.     'The DebugFlag is the provision which turns off all error checking in the table class when false
  67.     If Not objConfiguration.DebugFlag Then
  68.         On Error GoTo NoEmployeeCreateTable
  69.     End If
  70.  
  71.  
  72.     'Assemble the SQL String
  73.     lsCreate = "Create Table EMPLOYEE ("
  74.     lsCreate = lsCreate & "Employee_Id Long(4),"
  75.     lsCreate = lsCreate & "Employee_Name String(100),"
  76.     lsCreate = lsCreate & "Employee_SS String(11),"
  77.     lsCreate = lsCreate & "Updated_By String(50),"
  78.     lsCreate = lsCreate & "Update_Module String(50),"
  79.     lsCreate = lsCreate & "Update_Time Date/Time(8))"
  80.  
  81.     'Execute the SQL
  82.     Dbtimesheet.Execute lsCreate
  83.     On Error GoTo 0
  84.     Exit Sub
  85.  
  86. NoEmployeeCreateTable:
  87.  
  88.     'Retry for a predermined number of times, set by the MaxRetries Constant
  89.     If BadCount < MaxRetries Then
  90.         'if we have been exceeded retries on a previous error in this routine,
  91.         'just give the remaining errors one try, and don't save these errors,
  92.         'the interest should be in the original error
  93.         If Success = False Then
  94.             Resume Next
  95.         Else
  96.             'increment the retry counter
  97.             BadCount = BadCount + 1
  98.             'Look for Database errors and see if you can fix the error by reconnecting
  99.             If Err = 3146 or Err = 3075 then
  100.                 'Try Reconnecting to the database, then
  101.                 'keep executing the same line of code in a hope that retries will
  102.                 'be the solution to the problem.
  103.                 On Error GoTo BadEmployeeCreateTableConnect
  104.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  105.                 On Error goto 0
  106.             End If
  107.             Resume 0
  108.         End If
  109.     Else
  110.         'At MaxRetries, flag a failure in the routine
  111.         Success = False
  112.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  113.         'get a reason why the error occurred
  114.         ErrorCode = Err
  115.         objError.ErrorCode = Err
  116.         objError.FunctionName = "clsEmployee.CreateTable"
  117.         If Err = 3146 then
  118.             objError.Message = "Employee, CreateTable " & vbcrlf & Errors(0) & " "
  119.             ErrorMessage = Errors(0)
  120.         Else
  121.             objError.Message = "Employee, CreateTable "
  122.             ErrorMessage = Error(Err)
  123.         End If
  124.         objError.SQL = lsCreate
  125.         objError.Display vbExclamation
  126.         'reset the counter
  127.         BadCount = 0
  128.         'and try to execute the next line of code in the routine
  129.         Resume Next
  130.     End If
  131.  
  132. BadEmployeeCreateTableConnect:
  133.     'You can put additional database reopening error checking here if necessary
  134.     Resume Next
  135.  
  136.  
  137. End Sub
  138.  
  139.  
  140. '********************************************************************************************************
  141. 'Title:     AddItem
  142. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  143. 'Purpose:   This method Adds Items to the Database after the Key properties
  144. '           of the class have been filled
  145. 'Parameters:None
  146. 'Return:    Nothing
  147. '********************************************************************************************************
  148. Public Sub AddItem()
  149.  
  150. Dim lsAdd as string
  151. Dim RetCode as integer, liCount as integer, BadCount as integer
  152.  
  153.     'The Success flag gets initialized to True and set to false if a trappable error occurs
  154.     Success = True
  155.     'The ErrorCode is the Err returned by VB for the Trapped Error
  156.     ErrorCode = False
  157.     'The DebugFlag is the provision which turns off all error checking in the table class when false
  158.     If Not objConfiguration.DebugFlag Then
  159.         On Error GoTo NoEmployeeAddItem
  160.     End If
  161.  
  162.     'First we assign all the properties to temp vars and set any blank dates to NULL, or put in the date delimiters (Database Dependent)
  163.     StoreProperties
  164.     SetDefaultDates
  165.  
  166.     'Now Pad fields with a space if the record cannot be added with zero length
  167.     PadFields
  168.  
  169.     'The Double Your Quotes routine doubles any single quotes in string type variables for SQL compatibility
  170.     DoubleYourQuotes
  171.  
  172.     'Assemble the SQL String
  173.     lsAdd = "Insert into EMPLOYEE ("
  174.     'First the Field List
  175.     lsAdd = lsAdd & "Employee_Id,"
  176.     lsAdd = lsAdd & "Employee_Name,"
  177.     lsAdd = lsAdd & "Employee_SS,"
  178.     lsAdd = lsAdd & "Updated_By,"
  179.     lsAdd = lsAdd & "Update_Module,"
  180.     lsAdd = lsAdd & "Update_Time)"
  181.     lsAdd = lsAdd & " Values("
  182.     'Now the Value List
  183.     lsAdd = lsAdd & "" & Format(Employee_Id) & ","
  184.     lsAdd = lsAdd & "'" & Employee_Name & "',"
  185.     lsAdd = lsAdd & "'" & Employee_SS & "',"
  186.     'These are the Audit Trail Fields
  187.     lsAdd = lsAdd & "'" & objConfiguration.LanId & "',"
  188.     lsAdd = lsAdd & "'" & objConfiguration.ModuleName & "',"
  189.     lsAdd = lsAdd & "#" & format(Now,"MM/DD/YYYY hh:mm:ss") & "#)"
  190.  
  191.     'Execute the SQL
  192.     Dbtimesheet.Execute lsAdd
  193.  
  194.     'Reassign the original values to the properties list
  195.     RetrieveProperties
  196.  
  197.     On Error GoTo 0
  198.     Exit Sub
  199.  
  200. NoEmployeeAddItem:
  201.  
  202.     'Retry for a predermined number of times, set by the MaxRetries Constant
  203.     If BadCount < MaxRetries Then
  204.         'if we have been exceeded retries on a previous error in this routine,
  205.         'just give the remaining errors one try, and don't save these errors,
  206.         'the interest should be in the original error
  207.         If Success = False Then
  208.             Resume Next
  209.         Else
  210.             'increment the retry counter
  211.             BadCount = BadCount + 1
  212.             'Look for Database errors and see if you can fix the error by reconnecting
  213.             If Err = 3146 or Err = 3075 then
  214.                 'Try Reconnecting to the database, then
  215.                 'keep executing the same line of code in a hope that retries will
  216.                 'be the solution to the problem.
  217.                 On Error GoTo BadEmployeeAddItemConnect
  218.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  219.                 On Error goto 0
  220.             End If
  221.             Resume 0
  222.         End If
  223.     Else
  224.         'At MaxRetries, flag a failure in the routine
  225.         Success = False
  226.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  227.         'get a reason why the error occurred
  228.         ErrorCode = Err
  229.         objError.ErrorCode = Err
  230.         objError.FunctionName = "clsEmployee.AddItem"
  231.         If Err = 3146 then
  232.             objError.Message = "Employee, AddItem " & vbcrlf & Errors(0) & " "
  233.             ErrorMessage = Errors(0)
  234.         Else
  235.             objError.Message = "Employee, AddItem "
  236.             ErrorMessage = Error(Err)
  237.         End If
  238.         objError.SQL = lsAdd
  239.         objError.Display vbExclamation
  240.         'reset the counter
  241.         BadCount = 0
  242.         'and try to execute the next line of code in the routine
  243.         Resume Next
  244.     End If
  245.  
  246. BadEmployeeAddItemConnect:
  247.     'You can put additional database reopening error checking here if necessary
  248.     Resume Next
  249.  
  250.  
  251. End Sub
  252.  
  253. '********************************************************************************************************
  254. 'Title:     ClearValues
  255. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  256. 'Purpose:   This method clears all fields in the Table class
  257. 'Parameters:None
  258. 'Return:    Nothing
  259. '********************************************************************************************************
  260. Sub ClearValues()
  261.  
  262.     Employee_Id = 0
  263.     Employee_Name = ""
  264.     Employee_SS = ""
  265.     Updated_By = ""
  266.     Update_Module = ""
  267.     Update_Time = ""
  268.  
  269. End Sub
  270.  
  271.  
  272. '********************************************************************************************************
  273. 'Title:     DeleteItem
  274. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  275. 'Purpose:   This method Deletes Items from the Database after the Key fields have been filled
  276. 'Parameters:None
  277. 'Return:    Nothing
  278. '********************************************************************************************************
  279. Public Sub DeleteItem()
  280.  
  281. Dim lrsEmployee as RecordSet, lsDelete as string
  282. Dim RetCode as integer,lsCount as integer,liCount as integer,BadCount as integer
  283.  
  284.     'The Success flag gets initialized to True and set to false if a trappable error occurs
  285.     Success = True
  286.     'The ErrorCode is the Err returned by VB for the Trapped Error
  287.     ErrorCode = False
  288.     'The DebugFlag is the provision which turns off all error checking in the table class when false
  289.     If Not objConfiguration.DebugFlag Then
  290.         On Error GoTo NoEmployeeDeleteItem
  291.     End If
  292.  
  293.     'First we assign all the properties to temp vars and set any blank dates to NULL, or put in the date delimiters (Database Dependent)
  294.     StoreProperties
  295.     SetDefaultDates
  296.  
  297.     'Now Pad fields with a space if the record cannot be added with zero length
  298.     PadFields
  299.  
  300.     'The Double Your Quotes routine doubles any single quotes in string type variables for SQL compatibility
  301.     DoubleYourQuotes
  302.  
  303.     'Assemble the SQL String
  304.     lsDelete = "Delete from EMPLOYEE  where Employee_Id = " & Format(Employee_Id) & ""
  305.  
  306.     'Execute the SQL
  307.      Dbtimesheet.Execute lsDelete
  308.  
  309.     'Now ReAssign the Temp vars back to the class props
  310.     RetrieveProperties
  311.  
  312.     On Error GoTo 0
  313.     Exit Sub
  314.  
  315. NoEmployeeDeleteItem:
  316.  
  317.     'Retry for a predermined number of times, set by the MaxRetries Constant
  318.     If BadCount < MaxRetries Then
  319.         'if we have been exceeded retries on a previous error in this routine,
  320.         'just give the remaining errors one try, and don't save these errors,
  321.         'the interest should be in the original error
  322.         If Success = False Then
  323.             Resume Next
  324.         Else
  325.             'increment the retry counter
  326.             BadCount = BadCount + 1
  327.             'Look for Database errors and see if you can fix the error by reconnecting
  328.             If Err = 3146 or Err = 3075 then
  329.                 'Try Reconnecting to the database, then
  330.                 'keep executing the same line of code in a hope that retries will
  331.                 'be the solution to the problem.
  332.                 On Error GoTo BadEmployeeDeleteItemConnect
  333.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  334.                 On Error goto 0
  335.             End If
  336.             Resume 0
  337.         End If
  338.     Else
  339.         'At MaxRetries, flag a failure in the routine
  340.         Success = False
  341.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  342.         'get a reason why the error occurred
  343.         ErrorCode = Err
  344.         objError.ErrorCode = Err
  345.         objError.FunctionName = "clsEmployee.DeleteItem"
  346.         If Err = 3146 then
  347.             objError.Message = "Employee, DeleteItem " & vbcrlf & Errors(0) & " "
  348.             ErrorMessage = Errors(0)
  349.         Else
  350.             objError.Message = "Employee, DeleteItem "
  351.             ErrorMessage = Error(Err)
  352.         End If
  353.         objError.SQL = lsDelete
  354.         objError.Display vbExclamation
  355.         'reset the counter
  356.         BadCount = 0
  357.         'and try to execute the next line of code in the routine
  358.         Resume Next
  359.     End If
  360.  
  361. BadEmployeeDeleteItemConnect:
  362.     'You can put additional database reopening error checking here if necessary
  363.     Resume Next
  364.  
  365.  
  366. End Sub
  367.  
  368.  
  369. '********************************************************************************************************
  370. 'Title:     FillObjectFromRecordset
  371. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  372. 'Purpose    This sub fills all the properties of the class from a given recordset
  373. 'Parameters:The recordset from which to fill
  374. 'Return:    Nothing
  375. '********************************************************************************************************
  376. Public Sub FillObjectFromRecordSet(lrsEmployee as RecordSet)
  377.  
  378. Dim liCount as Integer, BadCount as Integer, pSQL as String, lsSelect as String
  379.     If Not objConfiguration.DebugFlag Then
  380.         On Error GoTo NoEmployeeFillObject
  381.     End If
  382.  
  383.     'Appending a & "" onto the end of a recordset field checks for Null values
  384.     'Similarly, Numbers are explicitly converted to eliminate Null values as well
  385.     Employee_Id = Val(lrsEmployee![Employee_Id] & "")
  386.     Employee_Name = lrsEmployee![Employee_Name] & ""
  387.     Employee_SS = lrsEmployee![Employee_SS] & ""
  388.     Updated_By = lrsEmployee![Updated_By] & ""
  389.     Update_Module = lrsEmployee![Update_Module] & ""
  390.     Update_Time = lrsEmployee![Update_Time] & ""
  391.     On Error GoTo 0
  392.     Exit Sub
  393.  
  394. NoEmployeeFillObject:
  395.  
  396.     'Retry for a predermined number of times, set by the MaxRetries Constant
  397.     If BadCount < MaxRetries Then
  398.         'if we have been exceeded retries on a previous error in this routine,
  399.         'just give the remaining errors one try, and don't save these errors,
  400.         'the interest should be in the original error
  401.         If Success = False Then
  402.             Resume Next
  403.         Else
  404.             'increment the retry counter
  405.             BadCount = BadCount + 1
  406.             'Look for Database errors and see if you can fix the error by reconnecting
  407.             If Err = 3146 or Err = 3075 then
  408.                 'Try Reconnecting to the database, then
  409.                 'keep executing the same line of code in a hope that retries will
  410.                 'be the solution to the problem.
  411.                 On Error GoTo BadEmployeeFillObjectConnect
  412.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  413.                 On Error goto 0
  414.             End If
  415.             Resume 0
  416.         End If
  417.     Else
  418.         'At MaxRetries, flag a failure in the routine
  419.         Success = False
  420.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  421.         'get a reason why the error occurred
  422.         ErrorCode = Err
  423.         objError.ErrorCode = Err
  424.         objError.FunctionName = "clsEmployee.FillObject"
  425.         If Err = 3146 then
  426.             objError.Message = "Employee, FillObject " & vbcrlf & Errors(0) & " "
  427.             ErrorMessage = Errors(0)
  428.         Else
  429.             objError.Message = "Employee, FillObject "
  430.             ErrorMessage = Error(Err)
  431.         End If
  432.         objError.SQL = lsSelect
  433.         objError.Display vbExclamation
  434.         'reset the counter
  435.         BadCount = 0
  436.         'and try to execute the next line of code in the routine
  437.         Resume Next
  438.     End If
  439.  
  440. BadEmployeeFillObjectConnect:
  441.     'You can put additional database reopening error checking here if necessary
  442.     Resume Next
  443.  
  444.  
  445. End Sub
  446.  
  447.  
  448. '********************************************************************************************************
  449. 'Title:     GetItem
  450. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  451. 'Purpose:   This Method Gets a record from the database after the Key Fields have been Filled
  452. 'Parameters:The recordset from which to fill
  453. 'Return:    Nothing
  454. '********************************************************************************************************
  455. Public Sub GetItem()
  456.  
  457. Dim lrsGetItem as RecordSet, lsSelect as string
  458. Dim RetCode as integer,lsCount as integer,liCount as integer,BadCount as integer
  459.  
  460.     'The Success flag gets initialized to True and set to false if a trappable error occurs
  461.     Success = True
  462.     'The ErrorCode is the Err returned by VB for the Trapped Error
  463.     ErrorCode = False
  464.     'The DebugFlag is the provision which turns off all error checking in the table class when false
  465.     If Not objConfiguration.DebugFlag Then
  466.         On Error GoTo NoEmployeeGetItem
  467.     End If
  468.  
  469.     'First we assign all the properties to temp vars and set any blank dates to NULL, or put in the date delimiters (Database Dependent)
  470.     StoreProperties
  471.     SetDefaultDates
  472.  
  473.     'Now Pad fields with a space if the record cannot be added with zero length
  474.     PadFields
  475.  
  476.     'The Double Your Quotes routine doubles any single quotes in string type variables for SQL compatibility
  477.     DoubleYourQuotes
  478.  
  479.     'Assemble the SQL String
  480.     lsSelect = "Select * from EMPLOYEE  where Employee_Id = " & Format(Employee_Id) & ""
  481.  
  482.     'Execute the SQL
  483.      Set lrsGetItem = Dbtimesheet.OpenRecordSet(lsSelect)
  484.  
  485.     'Now ReAssign the Temp vars back to the class props
  486.     RetrieveProperties
  487.  
  488.     'Check for a valid record
  489.     If Not Success Then
  490.         Exit Sub
  491.     End If
  492.     If lrsGetItem.RecordCount = 0 Then
  493.         Success = False
  494.         Exit Sub
  495.     End If
  496.  
  497.     'Fill the Table Class Fields from the Recordset
  498.     FillObjectFromRecordset lrsGetItem
  499.     'Check for Errors    
  500.     if not Success then
  501.         Exit sub
  502.     end if
  503.     lrsGetItem.Close
  504.  
  505.     'Now trim the spaces out of the padded fields
  506.     TrimPaddedFields
  507.  
  508.     'Strip the NULLs or bad dates out of date fields
  509.     StripDates False
  510.  
  511.     On Error GoTo 0
  512.     Exit Sub
  513.  
  514. NoEmployeeGetItem:
  515.  
  516.     'Retry for a predermined number of times, set by the MaxRetries Constant
  517.     If BadCount < MaxRetries Then
  518.         'if we have been exceeded retries on a previous error in this routine,
  519.         'just give the remaining errors one try, and don't save these errors,
  520.         'the interest should be in the original error
  521.         If Success = False Then
  522.             Resume Next
  523.         Else
  524.             'increment the retry counter
  525.             BadCount = BadCount + 1
  526.             'Look for Database errors and see if you can fix the error by reconnecting
  527.             If Err = 3146 or Err = 3075 then
  528.                 'Try Reconnecting to the database, then
  529.                 'keep executing the same line of code in a hope that retries will
  530.                 'be the solution to the problem.
  531.                 On Error GoTo BadEmployeeGetItemConnect
  532.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  533.                 On Error goto 0
  534.             End If
  535.             Resume 0
  536.         End If
  537.     Else
  538.         'At MaxRetries, flag a failure in the routine
  539.         Success = False
  540.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  541.         'get a reason why the error occurred
  542.         ErrorCode = Err
  543.         objError.ErrorCode = Err
  544.         objError.FunctionName = "clsEmployee.GetItem"
  545.         If Err = 3146 then
  546.             objError.Message = "Employee, GetItem " & vbcrlf & Errors(0) & " "
  547.             ErrorMessage = Errors(0)
  548.         Else
  549.             objError.Message = "Employee, GetItem "
  550.             ErrorMessage = Error(Err)
  551.         End If
  552.         objError.SQL = lsSelect
  553.         objError.Display vbExclamation
  554.         'reset the counter
  555.         BadCount = 0
  556.         'and try to execute the next line of code in the routine
  557.         Resume Next
  558.     End If
  559.  
  560. BadEmployeeGetItemConnect:
  561.     'You can put additional database reopening error checking here if necessary
  562.     Resume Next
  563.  
  564.  
  565. End Sub
  566.  
  567.  
  568. '********************************************************************************************************
  569. 'Title:     GetNewId
  570. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  571. 'Purpose:   This Method Gets a new Id using the Max function in SQL, it has only limited value, but is included as
  572. '           a template for new Primary Key generation
  573. 'Parameters:None
  574. 'Return:    Nothing
  575. '********************************************************************************************************
  576. Public function GetNewId() as double
  577.  
  578. Dim lrsGetNewId as RecordSet, lsSelect as string
  579. Dim RetCode as integer,liCount as integer,BadCount as integer
  580.  
  581.     'The Success flag gets initialized to True and set to false if a trappable error occurs
  582.     Success = True
  583.     'The ErrorCode is the Err returned by VB for the Trapped Error
  584.     ErrorCode = False
  585.     'The DebugFlag is the provision which turns off all error checking in the table class when false
  586.     If Not objConfiguration.DebugFlag Then
  587.         On Error GoTo NoEmployeeGetNewId
  588.     End If
  589.  
  590.     'First we assign all the date and text properties to temp vars and set any blank dates to NULL, or put in the date delimiters (Database Dependent)
  591.     StoreProperties
  592.     SetDefaultDates
  593.  
  594.     'Now Pad fields with a space if the record cannot be added with zero length
  595.     PadFields
  596.  
  597.     'The Double Your Quotes routine doubles any single quotes in string type variables for SQL compatibility
  598.     DoubleYourQuotes
  599.  
  600.  
  601.     'The SQL provided here is just a simple Get Max.  This would only be useful for very small tables
  602.     'If you anticipate this table growing past a few hundred rows, change this routine accordingly
  603.     'You might try keeping a table with the last Id stored as a field, which can then be updated when a 
  604.     'new Id is required.
  605.  
  606.     'Assemble the SQL String
  607.     lsSelect = "Select Max(Employee_Id) from EMPLOYEE 
  608.  
  609.     'Execute the SQL
  610.     Set lrsGetNewId = Dbtimesheet.OpenRecordSet(lsSelect)
  611.  
  612.     'Now ReAssign the Temp vars back to the class props
  613.     RetrieveProperties
  614.  
  615.     'Don't forget to check for those NULLS
  616.     If Not IsNull(lrsGetNewId(0)) Then
  617.         GetNewId = lrsGetNewId(0) + 1
  618.     Else
  619.         GetNewId = 1
  620.     End If
  621.     lrsGetNewId.Close
  622.     On Error GoTo 0
  623.     Exit Function
  624.  
  625. NoEmployeeGetNewId:
  626.  
  627.     'Retry for a predermined number of times, set by the MaxRetries Constant
  628.     If BadCount < MaxRetries Then
  629.         'if we have been exceeded retries on a previous error in this routine,
  630.         'just give the remaining errors one try, and don't save these errors,
  631.         'the interest should be in the original error
  632.         If Success = False Then
  633.             Resume Next
  634.         Else
  635.             'increment the retry counter
  636.             BadCount = BadCount + 1
  637.             'Look for Database errors and see if you can fix the error by reconnecting
  638.             If Err = 3146 or Err = 3075 then
  639.                 'Try Reconnecting to the database, then
  640.                 'keep executing the same line of code in a hope that retries will
  641.                 'be the solution to the problem.
  642.                 On Error GoTo BadEmployeeGetNewIdConnect
  643.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  644.                 On Error goto 0
  645.             End If
  646.             Resume 0
  647.         End If
  648.     Else
  649.         'At MaxRetries, flag a failure in the routine
  650.         Success = False
  651.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  652.         'get a reason why the error occurred
  653.         ErrorCode = Err
  654.         objError.ErrorCode = Err
  655.         objError.FunctionName = "clsEmployee.GetNewId"
  656.         If Err = 3146 then
  657.             objError.Message = "Employee, GetNewId " & vbcrlf & Errors(0) & " "
  658.             ErrorMessage = Errors(0)
  659.         Else
  660.             objError.Message = "Employee, GetNewId "
  661.             ErrorMessage = Error(Err)
  662.         End If
  663.         objError.SQL = lsSelect
  664.         objError.Display vbExclamation
  665.         'reset the counter
  666.         BadCount = 0
  667.         'and try to execute the next line of code in the routine
  668.         Resume Next
  669.     End If
  670.  
  671. BadEmployeeGetNewIdConnect:
  672.     'You can put additional database reopening error checking here if necessary
  673.     Resume Next
  674.  
  675.  
  676. End Function
  677.  
  678.  
  679. '********************************************************************************************************
  680. 'Title:     ParseItem
  681. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  682. 'Purpose:   This method can parse fields which have values in them.  It will create an SQL criteria string
  683. '           using like statements for strings, and = statements for numbers and dates, this can be used
  684. '           in Query by Example screens with little or no modification
  685. 'Parameters:None
  686. 'Return:    The Parsed String for use in SQL
  687. '********************************************************************************************************
  688. Public Function ParseItem(piAndFlag as Integer) As String
  689.  
  690. Dim RetCode as integer,liCount as integer,Buf1 as String
  691. Dim BadCount as integer, WildCard As String
  692.  
  693.     'The Success flag gets initialized to True and set to false if a trappable error occurs
  694.     Success = True
  695.     'The ErrorCode is the Err returned by VB for the Trapped Error
  696.     ErrorCode = False
  697.     'The DebugFlag is the provision which turns off all error checking in the table class when false
  698.     If Not objConfiguration.DebugFlag Then
  699.         On Error GoTo NoEmployeeParseItem
  700.     End If
  701.  
  702.     'Change this based on your database, MS-Access uses the *, but SQL standard is the %
  703.     wildcard = "*'"
  704.     
  705.     'First we assign all the date and text properties to temp vars and set any blank dates to NULL, or put in the date delimiters (Database Dependent)
  706.     StoreProperties
  707.     SetDefaultDates
  708.  
  709.     'Now Pad fields with a space if the record cannot be added with zero length
  710.     PadFields
  711.     'The Double Your Quotes routine doubles any single quotes in string type variables for SQL compatibility
  712.     DoubleYourQuotes
  713.  
  714.  
  715.     If Employee_Id <> 0 Then
  716.         If piAndFlag Then
  717.             Buf1 = Buf1 & " And "
  718.         Else
  719.             Buf1 = Buf1 & " Where "
  720.         End If
  721.         Buf1 = Buf1 & "Employee.Employee_Id = " & Format(Employee_Id)
  722.         piAndFlag = True
  723.     End If
  724.  
  725.     If Trim(Employee_Name) <> "" Then
  726.         If piAndFlag Then
  727.             Buf1 = Buf1 & " And "
  728.         Else
  729.             Buf1 = Buf1 & " Where "
  730.         End If
  731.         Buf1 = Buf1 & "Employee.Employee_Name like '" & Trim(Employee_Name) & WildCard
  732.         piAndFlag = True
  733.     End If
  734.  
  735.     If Trim(Employee_SS) <> "" Then
  736.         If piAndFlag Then
  737.             Buf1 = Buf1 & " And "
  738.         Else
  739.             Buf1 = Buf1 & " Where "
  740.         End If
  741.         Buf1 = Buf1 & "Employee.Employee_SS like '" & Trim(Employee_SS) & WildCard
  742.         piAndFlag = True
  743.     End If
  744.  
  745.     If Trim(Updated_By) <> "" Then
  746.         If piAndFlag Then
  747.             Buf1 = Buf1 & " And "
  748.         Else
  749.             Buf1 = Buf1 & " Where "
  750.         End If
  751.         Buf1 = Buf1 & "Employee.Updated_By like '" & Trim(Updated_By) & WildCard
  752.         piAndFlag = True
  753.     End If
  754.  
  755.     If Trim(Update_Module) <> "" Then
  756.         If piAndFlag Then
  757.             Buf1 = Buf1 & " And "
  758.         Else
  759.             Buf1 = Buf1 & " Where "
  760.         End If
  761.         Buf1 = Buf1 & "Employee.Update_Module like '" & Trim(Update_Module) & WildCard
  762.         piAndFlag = True
  763.     End If
  764.  
  765.     if isDate(Update_Time) then
  766.         If piAndFlag Then
  767.             Buf1 = Buf1 & " And "
  768.         Else
  769.             Buf1 = Buf1 & " Where "
  770.         End If
  771.         Buf1 = Buf1 & "Employee.Update_Time = " & Update_Time
  772.         piAndFlag = True
  773.     End If
  774.  
  775.     'now reassign the temp values back to the properties
  776.     RetrieveProperties
  777.  
  778.     On Error GoTo 0
  779.     ParseItem = Buf1
  780.     Exit Function
  781.  
  782. NoEmployeeParseItem:
  783.  
  784.     'Retry for a predermined number of times, set by the MaxRetries Constant
  785.     If BadCount < MaxRetries Then
  786.         'if we have been exceeded retries on a previous error in this routine,
  787.         'just give the remaining errors one try, and don't save these errors,
  788.         'the interest should be in the original error
  789.         If Success = False Then
  790.             Resume Next
  791.         Else
  792.             'increment the retry counter
  793.             BadCount = BadCount + 1
  794.             'Look for Database errors and see if you can fix the error by reconnecting
  795.             If Err = 3146 or Err = 3075 then
  796.                 'Try Reconnecting to the database, then
  797.                 'keep executing the same line of code in a hope that retries will
  798.                 'be the solution to the problem.
  799.                 On Error GoTo BadEmployeeParseItemConnect
  800.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  801.                 On Error goto 0
  802.             End If
  803.             Resume 0
  804.         End If
  805.     Else
  806.         'At MaxRetries, flag a failure in the routine
  807.         Success = False
  808.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  809.         'get a reason why the error occurred
  810.         ErrorCode = Err
  811.         objError.ErrorCode = Err
  812.         objError.FunctionName = "clsEmployee.ParseItem"
  813.         If Err = 3146 then
  814.             objError.Message = "Employee, ParseItem " & vbcrlf & Errors(0) & " "
  815.             ErrorMessage = Errors(0)
  816.         Else
  817.             objError.Message = "Employee, ParseItem "
  818.             ErrorMessage = Error(Err)
  819.         End If
  820.         objError.SQL = Buf1
  821.         objError.Display vbExclamation
  822.         'reset the counter
  823.         BadCount = 0
  824.         'and try to execute the next line of code in the routine
  825.         Resume Next
  826.     End If
  827.  
  828. BadEmployeeParseItemConnect:
  829.     'You can put additional database reopening error checking here if necessary
  830.     Resume Next
  831.  
  832.  
  833. End Function
  834.  
  835.  
  836. '********************************************************************************************************
  837. 'Title:     UpdateItem
  838. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  839. 'Purpose:   This method updates a record in the database using the primary key, it is recommended that you
  840. '           Fill the Key Fields, use the get method, fill the fields which have changed, 
  841. '           then call this method to perform the update
  842. 'Parameters:None
  843. 'Return:    Nothing
  844. '********************************************************************************************************
  845. Public Sub UpdateItem()
  846.  
  847. Dim lsUpdate as string
  848. Dim RetCode as integer, liCount as integer, BadCount as integer
  849.  
  850.     'The Success flag gets initialized to True and set to false if a trappable error occurs
  851.     Success = True
  852.     'The ErrorCode is the Err returned by VB for the Trapped Error
  853.     ErrorCode = False
  854.     'The DebugFlag is the provision which turns off all error checking in the table class when false
  855.     If Not objConfiguration.DebugFlag Then
  856.         On Error GoTo NoEmployeeUpdateItem
  857.     End If
  858.  
  859.     'First we will assign the date properties to temp vars and set any blank dates to NULL, or put in the date delimiters (Database Dependent)
  860.     StoreProperties
  861.     SetDefaultDates
  862.  
  863.     'Now Pad fields with a space if the record cannot be added with zero length
  864.     PadFields
  865.  
  866.     'The Double Your Quotes routine doubles any single quotes in string type variables for SQL compatibility
  867.     DoubleYourQuotes
  868.  
  869.     'Assemble the SQL String
  870.     lsUpdate = "Update EMPLOYEE Set "
  871.     lsUpdate = lsUpdate & "Employee_Name = '" & Employee_Name & "',"
  872.     lsUpdate = lsUpdate & "Employee_SS = '" & Employee_SS & "',"
  873.     'These are the Audit Trail Fields
  874.     lsUpdate = lsUpdate & "Updated_By = '" & objConfiguration.LanId & "',"
  875.     lsUpdate = lsUpdate & "Update_Module = '" & objConfiguration.ModuleName & "',"
  876.     lsUpdate = lsUpdate & "Update_Time = #" & format(Now,"MM/DD/YYYY hh:mm:ss") & "# "
  877.     lsUpdate = lsUpdate & " where Employee_Id = " & Format(Employee_Id) & ""
  878.  
  879.     'Execute the SQL
  880.     Dbtimesheet.Execute lsUpdate
  881.  
  882.     'now reassign the temp values back to the properties
  883.     RetrieveProperties
  884.  
  885.     On Error GoTo 0
  886.     Exit Sub
  887.  
  888. NoEmployeeUpdateItem:
  889.  
  890.     'Retry for a predermined number of times, set by the MaxRetries Constant
  891.     If BadCount < MaxRetries Then
  892.         'if we have been exceeded retries on a previous error in this routine,
  893.         'just give the remaining errors one try, and don't save these errors,
  894.         'the interest should be in the original error
  895.         If Success = False Then
  896.             Resume Next
  897.         Else
  898.             'increment the retry counter
  899.             BadCount = BadCount + 1
  900.             'Look for Database errors and see if you can fix the error by reconnecting
  901.             If Err = 3146 or Err = 3075 then
  902.                 'Try Reconnecting to the database, then
  903.                 'keep executing the same line of code in a hope that retries will
  904.                 'be the solution to the problem.
  905.                 On Error GoTo BadEmployeeUpdateItemConnect
  906.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  907.                 On Error goto 0
  908.             End If
  909.             Resume 0
  910.         End If
  911.     Else
  912.         'At MaxRetries, flag a failure in the routine
  913.         Success = False
  914.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  915.         'get a reason why the error occurred
  916.         ErrorCode = Err
  917.         objError.ErrorCode = Err
  918.         objError.FunctionName = "clsEmployee.UpdateItem"
  919.         If Err = 3146 then
  920.             objError.Message = "Employee, UpdateItem " & vbcrlf & Errors(0) & " "
  921.             ErrorMessage = Errors(0)
  922.         Else
  923.             objError.Message = "Employee, UpdateItem "
  924.             ErrorMessage = Error(Err)
  925.         End If
  926.         objError.SQL = lsUpdate
  927.         objError.Display vbExclamation
  928.         'reset the counter
  929.         BadCount = 0
  930.         'and try to execute the next line of code in the routine
  931.         Resume Next
  932.     End If
  933.  
  934. BadEmployeeUpdateItemConnect:
  935.     'You can put additional database reopening error checking here if necessary
  936.     Resume Next
  937.  
  938.  
  939. End Sub
  940.  
  941. '********************************************************************************************************
  942. 'Title:     DoubleYourQuotes
  943. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  944. 'Purpose:   This routine Doubles your Single Quotes in all string or memo 
  945. '           fields in the class for SQL compatibility
  946. 'Parameters:None
  947. 'Return:    Nothing
  948. '********************************************************************************************************
  949. Private Sub DoubleYourQuotes()
  950.  
  951. Dim liCount as integer,BadCount as integer
  952.  
  953.     If Not objConfiguration.DebugFlag Then
  954.         On Error GoTo NoEmployeeDoubleYourQuotes
  955.     End If
  956.  
  957.     'These lines double the single quotes in any string field in the class
  958.     Employee_Name = SearchandDouble(Employee_Name)
  959.     Employee_SS = SearchandDouble(Employee_SS)
  960.     Updated_By = SearchandDouble(Updated_By)
  961.     Update_Module = SearchandDouble(Update_Module)
  962.     On Error GoTo 0
  963.     Exit Sub
  964.  
  965. NoEmployeeDoubleYourQuotes:
  966.  
  967.     'Retry for a predermined number of times, set by the MaxRetries Constant
  968.     If BadCount < MaxRetries Then
  969.         'if we have been exceeded retries on a previous error in this routine,
  970.         'just give the remaining errors one try, and don't save these errors,
  971.         'the interest should be in the original error
  972.         If Success = False Then
  973.             Resume Next
  974.         Else
  975.             'increment the retry counter
  976.             BadCount = BadCount + 1
  977.             'Look for Database errors and see if you can fix the error by reconnecting
  978.             If Err = 3146 or Err = 3075 then
  979.                 'Try Reconnecting to the database, then
  980.                 'keep executing the same line of code in a hope that retries will
  981.                 'be the solution to the problem.
  982.                 On Error GoTo BadEmployeeDoubleYourQuotesConnect
  983.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  984.                 On Error goto 0
  985.             End If
  986.             Resume 0
  987.         End If
  988.     Else
  989.         'At MaxRetries, flag a failure in the routine
  990.         Success = False
  991.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  992.         'get a reason why the error occurred
  993.         ErrorCode = Err
  994.         objError.ErrorCode = Err
  995.         objError.FunctionName = "clsEmployee.DoubleYourQuotes"
  996.         If Err = 3146 then
  997.             objError.Message = "Employee, DoubleYourQuotes " & vbcrlf & Errors(0) & " "
  998.             ErrorMessage = Errors(0)
  999.         Else
  1000.             objError.Message = "Employee, DoubleYourQuotes "
  1001.             ErrorMessage = Error(Err)
  1002.         End If
  1003.         objError.SQL = ""
  1004.         objError.Display vbExclamation
  1005.         'reset the counter
  1006.         BadCount = 0
  1007.         'and try to execute the next line of code in the routine
  1008.         Resume Next
  1009.     End If
  1010.  
  1011. BadEmployeeDoubleYourQuotesConnect:
  1012.     'You can put additional database reopening error checking here if necessary
  1013.     Resume Next
  1014.  
  1015.  
  1016. End Sub
  1017.  
  1018. '********************************************************************************************************
  1019. 'Title:     SearchandDouble
  1020. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  1021. 'Purpose:   This Function will look for any single quotes in a string passed to it
  1022. '           and double them for SQL compatibility
  1023. 'Parameters:string to be modified
  1024. 'Return:    the modified string
  1025. '********************************************************************************************************
  1026. Private Function SearchandDouble(lsBuf As String) As String
  1027.  
  1028. Dim liStrLen As Integer
  1029. Dim liCurChar As Integer
  1030. Dim liQuotePos As Integer
  1031. Dim lsQuote As String
  1032. Dim lsOutBuf As String
  1033.  
  1034.     lsQuote = "'"
  1035.     liCurChar = 1
  1036.     lsOutBuf = ""
  1037.     
  1038.     
  1039.     liQuotePos = InStr(liCurChar, lsBuf, lsQuote)
  1040.     If liQuotePos = 0 Then
  1041.         lsOutBuf = lsBuf
  1042.     Else
  1043.         liStrLen = Len(lsBuf)
  1044.         Do While liQuotePos > 0
  1045.             lsOutBuf = lsOutBuf & Mid(lsBuf, liCurChar, liQuotePos - liCurChar + 1) & lsQuote
  1046.             liCurChar = liQuotePos + 1
  1047.             liQuotePos = InStr(liCurChar, lsBuf, lsQuote)
  1048.         Loop
  1049.         lsOutBuf = lsOutBuf & Mid(lsBuf, liCurChar, liStrLen)
  1050.     End If
  1051.  
  1052.     SearchandDouble = lsOutBuf
  1053.  
  1054. End Function
  1055.  
  1056. '********************************************************************************************************
  1057. 'Title:     SetDefaultDates
  1058. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  1059. 'Purpose:   This routine puts default date or NULL into blank or invalid date fields
  1060. 'Parameters:None
  1061. 'Return:    Nothing
  1062. '********************************************************************************************************
  1063. Private Sub SetDefaultDates()
  1064.  
  1065. Dim liCount as integer,BadCount as integer
  1066.  
  1067.     If Not objConfiguration.DebugFlag Then
  1068.         On Error GoTo NoEmployeeSetDefaultDates
  1069.     End If
  1070.  
  1071.     'These lines look at the dates in the class, and put a NULL or your default date
  1072.      'depending on your data mode, when the date is
  1073.     'blank or invalid, since this is what sql expects
  1074.     if not isDate(Update_Time) then
  1075.         Update_Time = "NULL"
  1076.     Else
  1077.         Update_Time = "#" & format(CDate(Update_Time),"MM/DD/YYYY HH:MM:SS") & "#"
  1078.     Endif
  1079.     On Error GoTo 0
  1080.     Exit Sub
  1081.  
  1082. NoEmployeeSetDefaultDates:
  1083.  
  1084.     'Retry for a predermined number of times, set by the MaxRetries Constant
  1085.     If BadCount < MaxRetries Then
  1086.         'if we have been exceeded retries on a previous error in this routine,
  1087.         'just give the remaining errors one try, and don't save these errors,
  1088.         'the interest should be in the original error
  1089.         If Success = False Then
  1090.             Resume Next
  1091.         Else
  1092.             'increment the retry counter
  1093.             BadCount = BadCount + 1
  1094.             'Look for Database errors and see if you can fix the error by reconnecting
  1095.             If Err = 3146 or Err = 3075 then
  1096.                 'Try Reconnecting to the database, then
  1097.                 'keep executing the same line of code in a hope that retries will
  1098.                 'be the solution to the problem.
  1099.                 On Error GoTo BadEmployeeSetDefaultDatesConnect
  1100.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  1101.                 On Error goto 0
  1102.             End If
  1103.             Resume 0
  1104.         End If
  1105.     Else
  1106.         'At MaxRetries, flag a failure in the routine
  1107.         Success = False
  1108.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  1109.         'get a reason why the error occurred
  1110.         ErrorCode = Err
  1111.         objError.ErrorCode = Err
  1112.         objError.FunctionName = "clsEmployee.SetDefaultDates"
  1113.         If Err = 3146 then
  1114.             objError.Message = "Employee, SetDefaultDates " & vbcrlf & Errors(0) & " "
  1115.             ErrorMessage = Errors(0)
  1116.         Else
  1117.             objError.Message = "Employee, SetDefaultDates "
  1118.             ErrorMessage = Error(Err)
  1119.         End If
  1120.         objError.SQL = ""
  1121.         objError.Display vbExclamation
  1122.         'reset the counter
  1123.         BadCount = 0
  1124.         'and try to execute the next line of code in the routine
  1125.         Resume Next
  1126.     End If
  1127.  
  1128. BadEmployeeSetDefaultDatesConnect:
  1129.     'You can put additional database reopening error checking here if necessary
  1130.     Resume Next
  1131.  
  1132.  
  1133. End Sub
  1134.  
  1135. '********************************************************************************************************
  1136. 'Title:     StripDates
  1137. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  1138. 'Purpose:   This routine strips NULLS and bad Dates from Fields in the class, the delimiter field
  1139. '           determines whether it should check for the presence of Date Delimiters
  1140. 'Parameters:None
  1141. 'Return:    Nothing
  1142. '********************************************************************************************************
  1143. Private Sub StripDates(DelimiterFlag as integer)
  1144.  
  1145. Dim liCount as integer,BadCount as integer
  1146.  
  1147.     If Not objConfiguration.DebugFlag Then
  1148.         On Error GoTo NoEmployeeStripDates
  1149.     End If
  1150.  
  1151.     'These lines check to see if a NULL has been entered into the field from the
  1152.     'DefaultDate subroutine, if it has, it is set to an empty string, the date from
  1153.     'the database is also checked, if it is invalid, it to is set to an empty string
  1154.     if Update_Time = "NULL" then
  1155.         Update_Time = ""
  1156.     Endif
  1157.     On Error GoTo 0
  1158.     Exit Sub
  1159.  
  1160. NoEmployeeStripDates:
  1161.  
  1162.     'Retry for a predermined number of times, set by the MaxRetries Constant
  1163.     If BadCount < MaxRetries Then
  1164.         'if we have been exceeded retries on a previous error in this routine,
  1165.         'just give the remaining errors one try, and don't save these errors,
  1166.         'the interest should be in the original error
  1167.         If Success = False Then
  1168.             Resume Next
  1169.         Else
  1170.             'increment the retry counter
  1171.             BadCount = BadCount + 1
  1172.             'Look for Database errors and see if you can fix the error by reconnecting
  1173.             If Err = 3146 or Err = 3075 then
  1174.                 'Try Reconnecting to the database, then
  1175.                 'keep executing the same line of code in a hope that retries will
  1176.                 'be the solution to the problem.
  1177.                 On Error GoTo BadEmployeeStripDatesConnect
  1178.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  1179.                 On Error goto 0
  1180.             End If
  1181.             Resume 0
  1182.         End If
  1183.     Else
  1184.         'At MaxRetries, flag a failure in the routine
  1185.         Success = False
  1186.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  1187.         'get a reason why the error occurred
  1188.         ErrorCode = Err
  1189.         objError.ErrorCode = Err
  1190.         objError.FunctionName = "clsEmployee.StripDates"
  1191.         If Err = 3146 then
  1192.             objError.Message = "Employee, StripDates " & vbcrlf & Errors(0) & " "
  1193.             ErrorMessage = Errors(0)
  1194.         Else
  1195.             objError.Message = "Employee, StripDates "
  1196.             ErrorMessage = Error(Err)
  1197.         End If
  1198.         objError.SQL = ""
  1199.         objError.Display vbExclamation
  1200.         'reset the counter
  1201.         BadCount = 0
  1202.         'and try to execute the next line of code in the routine
  1203.         Resume Next
  1204.     End If
  1205.  
  1206. BadEmployeeStripDatesConnect:
  1207.     'You can put additional database reopening error checking here if necessary
  1208.     Resume Next
  1209.  
  1210.  
  1211. End Sub
  1212.  
  1213. '********************************************************************************************************
  1214. 'Title:     PadFields
  1215. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  1216. 'Purpose:   This routine Pads any fields with a space which do not allow zero length
  1217. 'Purpose:   The Allow zero length property is set by default in Access databases and is
  1218. '           used also in Oracle and SQLServer if the if fields are not padded with space
  1219. '           the database won't add the record, sometimes this is desirable sometimes not
  1220. 'Parameters:None
  1221. 'Return:    Nothing
  1222. '********************************************************************************************************
  1223. Private Sub PadFields()
  1224.  
  1225. Dim liCount as integer,BadCount as integer
  1226.  
  1227.     If Not objConfiguration.DebugFlag Then
  1228.         On Error GoTo NoEmployeePadFields
  1229.     End If
  1230.  
  1231.     'These lines put a space into any field which does not allow zero length, so the
  1232.     'record can be added anyway
  1233.     if Trim(Employee_Name) = "" then
  1234.             Employee_Name = " "
  1235.     Endif
  1236.     if Trim(Employee_SS) = "" then
  1237.             Employee_SS = " "
  1238.     Endif
  1239.     if Trim(Updated_By) = "" then
  1240.             Updated_By = " "
  1241.     Endif
  1242.     if Trim(Update_Module) = "" then
  1243.             Update_Module = " "
  1244.     Endif
  1245.     On Error GoTo 0
  1246.     Exit Sub
  1247.  
  1248. NoEmployeePadFields:
  1249.  
  1250.     'Retry for a predermined number of times, set by the MaxRetries Constant
  1251.     If BadCount < MaxRetries Then
  1252.         'if we have been exceeded retries on a previous error in this routine,
  1253.         'just give the remaining errors one try, and don't save these errors,
  1254.         'the interest should be in the original error
  1255.         If Success = False Then
  1256.             Resume Next
  1257.         Else
  1258.             'increment the retry counter
  1259.             BadCount = BadCount + 1
  1260.             'Look for Database errors and see if you can fix the error by reconnecting
  1261.             If Err = 3146 or Err = 3075 then
  1262.                 'Try Reconnecting to the database, then
  1263.                 'keep executing the same line of code in a hope that retries will
  1264.                 'be the solution to the problem.
  1265.                 On Error GoTo BadEmployeePadFieldsConnect
  1266.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  1267.                 On Error goto 0
  1268.             End If
  1269.             Resume 0
  1270.         End If
  1271.     Else
  1272.         'At MaxRetries, flag a failure in the routine
  1273.         Success = False
  1274.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  1275.         'get a reason why the error occurred
  1276.         ErrorCode = Err
  1277.         objError.ErrorCode = Err
  1278.         objError.FunctionName = "clsEmployee.PadFields"
  1279.         If Err = 3146 then
  1280.             objError.Message = "Employee, PadFields " & vbcrlf & Errors(0) & " "
  1281.             ErrorMessage = Errors(0)
  1282.         Else
  1283.             objError.Message = "Employee, PadFields "
  1284.             ErrorMessage = Error(Err)
  1285.         End If
  1286.         objError.SQL = ""
  1287.         objError.Display vbExclamation
  1288.         'reset the counter
  1289.         BadCount = 0
  1290.         'and try to execute the next line of code in the routine
  1291.         Resume Next
  1292.     End If
  1293.  
  1294. BadEmployeePadFieldsConnect:
  1295.     'You can put additional database reopening error checking here if necessary
  1296.     Resume Next
  1297.  
  1298.  
  1299. End Sub
  1300.  
  1301. '********************************************************************************************************
  1302. 'Title:     TrimPaddedFields
  1303. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  1304. 'Purpose:   This routine Trims the fields which have spaces at beginning or end
  1305. 'Parameters:None
  1306. 'Return:    Nothing
  1307. '********************************************************************************************************
  1308. Private Sub TrimPaddedFields()
  1309.  
  1310. Dim liCount as integer,BadCount as integer
  1311.  
  1312.     If Not objConfiguration.DebugFlag Then
  1313.         On Error GoTo NoEmployeeTrimPaddedFields
  1314.     End If
  1315.  
  1316.     'This routine deletes the spaces from any padded fields
  1317.     Employee_Name = Trim(Employee_Name)
  1318.     Employee_SS = Trim(Employee_SS)
  1319.     Updated_By = Trim(Updated_By)
  1320.     Update_Module = Trim(Update_Module)
  1321.     On Error GoTo 0
  1322.     Exit Sub
  1323.  
  1324. NoEmployeeTrimPaddedFields:
  1325.  
  1326.     'Retry for a predermined number of times, set by the MaxRetries Constant
  1327.     If BadCount < MaxRetries Then
  1328.         'if we have been exceeded retries on a previous error in this routine,
  1329.         'just give the remaining errors one try, and don't save these errors,
  1330.         'the interest should be in the original error
  1331.         If Success = False Then
  1332.             Resume Next
  1333.         Else
  1334.             'increment the retry counter
  1335.             BadCount = BadCount + 1
  1336.             'Look for Database errors and see if you can fix the error by reconnecting
  1337.             If Err = 3146 or Err = 3075 then
  1338.                 'Try Reconnecting to the database, then
  1339.                 'keep executing the same line of code in a hope that retries will
  1340.                 'be the solution to the problem.
  1341.                 On Error GoTo BadEmployeeTrimPaddedFieldsConnect
  1342.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  1343.                 On Error goto 0
  1344.             End If
  1345.             Resume 0
  1346.         End If
  1347.     Else
  1348.         'At MaxRetries, flag a failure in the routine
  1349.         Success = False
  1350.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  1351.         'get a reason why the error occurred
  1352.         ErrorCode = Err
  1353.         objError.ErrorCode = Err
  1354.         objError.FunctionName = "clsEmployee.TrimPaddedFields"
  1355.         If Err = 3146 then
  1356.             objError.Message = "Employee, TrimPaddedFields " & vbcrlf & Errors(0) & " "
  1357.             ErrorMessage = Errors(0)
  1358.         Else
  1359.             objError.Message = "Employee, TrimPaddedFields "
  1360.             ErrorMessage = Error(Err)
  1361.         End If
  1362.         objError.SQL = ""
  1363.         objError.Display vbExclamation
  1364.         'reset the counter
  1365.         BadCount = 0
  1366.         'and try to execute the next line of code in the routine
  1367.         Resume Next
  1368.     End If
  1369.  
  1370. BadEmployeeTrimPaddedFieldsConnect:
  1371.     'You can put additional database reopening error checking here if necessary
  1372.     Resume Next
  1373.  
  1374.  
  1375. End Sub
  1376.  
  1377.  
  1378. '********************************************************************************************************
  1379. 'Title:     StoreProperties
  1380. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  1381. 'Purpose    This Sub Assigns the Properties of the Class to the
  1382. '           private class scratchpad variables
  1383. 'Parameters:None
  1384. 'Return:    Nothing
  1385. '********************************************************************************************************
  1386. Private Sub StoreProperties()
  1387.  
  1388.     mEmployee_Id = Employee_Id
  1389.     mEmployee_Name = Employee_Name
  1390.     mEmployee_SS = Employee_SS
  1391.     mUpdated_By = Updated_By
  1392.     mUpdate_Module = Update_Module
  1393.     mUpdate_Time = Update_Time
  1394.  
  1395. End Sub
  1396.  
  1397. '********************************************************************************************************
  1398. 'Title:     RetrieveProperties
  1399. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  1400. 'Purpose    This Sub Assigns the ScratchPad Variable Values back to the Class properties
  1401. 'Parameters:None
  1402. 'Return:    Nothing
  1403. '********************************************************************************************************
  1404. Private Sub RetrieveProperties()
  1405.  
  1406.     Employee_Id = mEmployee_Id
  1407.     Employee_Name = mEmployee_Name
  1408.     Employee_SS = mEmployee_SS
  1409.     Updated_By = mUpdated_By
  1410.     Update_Module = mUpdate_Module
  1411.     Update_Time = mUpdate_Time
  1412.  
  1413. End Sub
  1414.